<?php
/* @var $this CategoryContentController */
/* @var $model CategoryContent */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'category-gallery-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Поля с <span class="required">*</span> должны быть заполнены.</p>

	<?php echo $form->errorSummary($model); ?>
	
	<div class="tabs">
		<a href="#tab_<?php echo Yii::app()->params->language; ?>" class="tab active"><?php echo Yii::app()->params->language; ?></a>
		<?php foreach(Yii::app()->params->languages as $key => $value): ?>
			<a href="#tab_<?php echo $key; ?>" class="tab"><?php echo $key; ?></a>
		<?php endforeach;?>
	</div>
	
	<div id="tab_<?php echo Yii::app()->params->language; ?>" class="screen visible">
		<div class="row">
			<?php echo $form->labelEx($model,'name'); ?>
			<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>255)); ?>
			<?php echo $form->error($model,'name'); ?>
		</div>

		<div class="row">
			<?php echo $form->labelEx($model,'parent_id'); ?>
			<?php echo $form->dropDownList($model,'parent_id',CSelect::items('CategoryGallery'),  array('empty' => ('Выберите категорию'))); ?>
			<?php echo $form->error($model,'parent_id'); ?>
		</div>

		<div class="row">
			<?php echo $form->labelEx($model,'description'); ?>
			<?php echo $form->textArea($model,'description'); ?>
			<?php echo $form->error($model,'description'); ?>
		</div>
		<div class="row">
			<?php echo $form->labelEx($model,'template'); ?>
			<?php echo $form->textField($model,'template',array('size'=>60,'maxlength'=>255)); ?>
			<?php echo $form->error($model,'template'); ?>
		</div>
		<div class="row">
			<?php echo $form->labelEx($model,'alias'); ?>
			<?php echo $form->textField($model,'alias',array('size'=>60,'maxlength'=>255)); ?>
			<?php echo $form->error($model,'alias'); ?>
		</div>
		<div class="row">
			<?php echo $form->labelEx($model,'onpage'); ?>
			<?php echo $form->textField($model,'onpage',array('size'=>60,'maxlength'=>255)); ?>
			<?php echo $form->error($model,'onpage'); ?>
		</div>
	</div>
	<?php 
	$lns = Yii::app()->params->languages; 
	$names = isset($model->lns) ? CHtml::listData($model->lns, 'ln', 'name') : array();
	$description = isset($model->lns) ? CHtml::listData($model->lns, 'ln', 'description') : array();
	foreach($lns as $key => $value) : 
	?>
	<div id="tab_<?php echo $key; ?>" class="screen">
		<div class="row">
			<?php echo $form->labelEx($model,'name'); ?>
			<?php echo $form->textField($model,'[lns]['.$key.']name',array('size'=>60,'maxlength'=>255, 'value'=> isset($names[$key]) ? $names[$key] : '' )); ?>
			<?php echo $form->error($model,'name'); ?>
		</div>
		<div class="row">
			<?php echo $form->labelEx($model,'description'); ?>
			<?php echo $form->textArea($model,'[lns]['.$key.']description', array('value'=> isset($description[$key]) ? $description[$key] : '' )); ?>
			<?php echo $form->error($model,'description'); ?>
		</div>
	</div>
	<?php endforeach;?>
<?php $this->endWidget(); ?>

</div><!-- form -->